using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ScoreCount
{
    static public bool active4X = false; 

	static bool Begin,end;
	 public struct Line
	{
		public int ID;
		public int Count;
		public int Type;
		public Line(int id,int count,int type )
		{ID = id; Count = count; Type = type;}
	}
	static XMLGems xml = new XMLGems();
	static int score;
	static int count = 0;
	static public int ComboForAmount = 1;
	static public int ComboForLineAmount = 1;
    static int x4 = 1;

	static public void scoreReset()
	{
		score = 0;
	}
	
	static public void ComboBegin()
	{
		Begin = true;
		end = false;
	}
	static public void ComboEnd()
	{
		ComboForLineAmount = 1;
		Begin = false;
		end = true;
	}
	
	static public int CountScore(Line Element)
	{	
        if (Begin)
        {
            ComboForLineAmount += 2;
		
            if (Element.Count == 4)
            {
                ComboForAmount += 2;
            }
            else
                if (Element.Count >= 5)
            {
                ComboForAmount += 4;
            }
            else
            {
                ComboForAmount = 1;
            }

            if (!active4X)
                x4 = 1;

            if (active4X)
                x4 = 4;
        }
		//Debug.Log (ComboForAmount);
			//	Debug.Log (ComboForLineAmount);
		int Plus = xml.GetScore(Element.Type) * Element.Count * ComboForAmount * ComboForLineAmount * x4;
				score += Plus;
				return Plus;
			//	Debug.Log (score);
				
		/*int AmountL = Element.Count;
		Debug.Log(AmountL);
		foreach(Line El in Element)
		{
		if(El.Count == 4)
		{
			ComboForAmount = 2;
		}
		else
			if(count >= 5)
			{
				ComboForAmount = 3;
			}
			else
			{
			ComboForAmount = 1;
			}
			if(AmountL == 2)
			{
				ComboForLineAmount = 2;
			}else
				if (AmountL == 3)
				{
					ComboForLineAmount = 4;
				}
			else
				if (AmountL >=4) 
				{
					ComboForLineAmount = 5;
				}
				score += xml.GetScore(El.Type)*El.Count * ComboForAmount * ComboForLineAmount;
		}*/
	}
	static public void StepCount()
	{
			count++;
	}
	
	static public int GetStepCount()
	{
		return count;
	}
	
	static public int GetScoreCount()
	{
		return score;
	}
	
}
